#!/bin/sh /etc/rc.common
#
# Copyright (C) 2017 Kyson.Lok <kysonlok@gmail.com>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#

START=99

USE_PROCD=1

start_instance() {
	local enable
	config_get_bool enable $1 enable
	[ "$enable" = 1 ] || return 0

	procd_open_instance
	procd_set_param respawn
	procd_set_param stderr 1
	procd_set_param command /usr/bin/mtk_wanstate
	procd_close_instance
}

start_service() {
	config_load mtk_wanstate
	config_foreach start_instance mtk_wanstate
}

service_triggers() {
	procd_add_reload_trigger "mtk_wanstate"
}
